package cn.edu.scau.cmi.linyiqu.composite.safe;

import java.util.HashSet;
import java.util.Set;

public class SafeTeam extends SafeComponent {
	private String name;

	private Set<SafeComponent> childrenSet = new HashSet<SafeComponent>();

	public SafeTeam(String name) {
		this.name = name;
	}

	@Override
	public String show(int indentation) {
		StringBuilder string = new StringBuilder();
		int i=indentation;
		while ((i--) > 0)
			string.append('\t');
		string.append("Team: " + this.name + '\n');
		for (SafeComponent children : childrenSet) {
			string.append(children.show(indentation + 1));
		}
		return string.toString();
	}

	public SafeComponent removeChild(SafeComponent child) {
		childrenSet.remove(child);
		return this;
	}

	public SafeComponent addChild(SafeComponent child) {
		childrenSet.add(child);
		return this;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<SafeComponent> getChildrenSet() {
		return childrenSet;
	}

	public void setChildrenSet(Set<SafeComponent> childrenSet) {
		this.childrenSet = childrenSet;
	}

}